package util;

public class Filter {
    static final String[] CARACTERES = {"{","}","(",")","\\[","\\]","<",">",
        ":",";",".",",","!","?","\\","/","~","`","\"","\'","\\\\",
        "=","+","\\-","*","@","#","$","%","^","&","_","\\|"};
 
    public static String filterChar(String texto){
        StringBuilder padrao = new StringBuilder();
        padrao.append("[^a-zA-Z0-9|");
        for (int i=0; i<CARACTERES.length;i++) {
            padrao.append(CARACTERES[i]);
            if(i<CARACTERES.length-1){
                padrao.append("|");
            }
        }
        padrao.append("]");
        //System.out.println(padrao.toString());
        return (texto.replaceAll(padrao.toString(), " "));
    }
        

    public static void main(String[] args) throws Exception {
        String x = "`rafael liberato roberto !@#$%^&*()_+=-{}[]\\;:'\"/><,.`~|123 4 43 33 4 65 { '¡¼¼³¤¤€¼¼½½¾‘¾’¥×";
        x = x + Character.toString('\u2122');
        System.out.println(x);
        System.out.println(filterChar(x));
    }
}
